#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main() {
    int n, m;
    scanf("%d %d", &n, &m);

    int arr1[1000] = { 0 };
    int arr2[1000] = { 0 };
    int arr3[1000] = { 0 };

    int i = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &arr1[i]);
    }

    for (i = 0; i < m; i++)
    {
        scanf("%d", &arr2[i]);
    }


    int x = 0;
    for (i = 0; i < m + n; i++)
    {
        if (i < n)
        {
            arr3[i] = arr1[i];
        }
        else
        {
            arr3[i] = arr2[x++];
        }
    }

    for (i = 0; i < m + n - 1; i++)
    {
        int j = 0;
        int flag = 0;
        for (j = 0; j < n + m - 1 - i; j++)
        {
            if (arr3[j] > arr3[j + 1])
            {
                int temp = arr3[j];
                arr3[j] = arr3[j + 1];
                arr3[j + 1] = temp;
                flag = 1;
            }
        }
        if (flag == 0)
        {
            break;
        }
    }

    for (i = 0; i < n + m; i++)
    {
        printf("%d ", arr3[i]);
    }
    return 0;
}